package appnumerico.web;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import appnumerico.code.IntervalosRaicesService;
import appnumerico.web.utils.WebUtils;

@Controller 
@RequestMapping("/luv/*")
public class LinealesUnaVariableController {
 
	private IntervalosRaicesService intervalosRaicesService;
	
	@Resource
	public void setIntervalosRaicesService(IntervalosRaicesService intervalosRaicesService) {
		this.intervalosRaicesService = intervalosRaicesService;
	}
	
	/**
	 * 
	 * http://localhost:8080/appn/index.jsp
	 * 
	 * @param map
	 * @param valorInicial
	 * @param deltaX
	 * @param n  
	 */
	
	@RequestMapping
	public void calculoIncremental(ModelMap map, HttpSession session,
			@RequestParam double valorInicial,
			@RequestParam double deltaX, 
			@RequestParam int n) {
		
		map.put("rbi", intervalosRaicesService.calculoBusquedaIncremental(WebUtils.getFuncion(session), valorInicial, deltaX, n));
		
	}
	
	@RequestMapping
	public String calculoIncrementalForm() {
		return "/luv/calculoIncremental";
	}
	
}
